{extend name="layout/popup" /}
{block name="content"}
<link rel="stylesheet" href="__ADMIN__/css/formSelects-v4.css"/>
<div class="space-10"></div>
<div class="td-content-wrap p20">
    <div class="td-content-header">
        <h1>异常信息管理</h1>
    </div>
    <hr>
    <div class="panel no-border">
        <div id="adv_search"></div>
        <span class="mid"></span>
        <a class="layui-btn" onclick="delAll();">一键删除</a>
    </div>
    <table id="data_table" lay-filter="data_table"></table>
</div>
{/block}

{block name="script"}
<script type="text/html" id="tool_bar">
    <a class="layui-btn layui-btn-danger layui-btn" lay-event="del">删除</a>
</script>
<script type="text/html" id="sort">
    <span class="handle" data-id="{{d.id}}" data-sort="{{d.sort}}"><i class="iconfont td-tuodong pointer"></i></span>
</script>
<script>
    layui.use(['element', 'data_table'], function () {
        let $ = layui.jquery;
        let data_table = layui.data_table;

        // 记录返回地址
        set_return_url(null);

        // 页面用到方法
        let fn = {
            delAll: function (data) {
                layer.msg('确定要删除吗?', {
                    time: 0,
                    btn: ['确定', '取消'],
                    yes: function (index) {
                        var vars = 'vids={$error_vids | default='0'}';
                        $.get("{:url('voteDel')}", vars, function (res) {
                            if (res.code) {
                                layer.msg(res.msg, {
                                    time: 1200
                                }, function () {
                                    location.reload(true);
                                });
                            } else {
                                layer.msg(res.msg, {time: 1200});
                            }
                        });
                    },
                    no: function (index) {
                        layer.close(index);
                    }
                });
            },
            del: function (data) {
                layer.msg('确定要删除吗?', {
                    time: 0,
                    btn: ['确定', '取消'],
                    yes: function (index) {
                        var vars = 'vids=' + data.id;
                        $.get("{:url('voteDel')}", vars, function (res) {
                            if (res.code) {
                                layer.msg(res.msg, {
                                    time: 1200
                                }, function () {
                                    location.reload(true);
                                });
                            } else {
                                layer.msg(res.msg, {time: 1200});
                            }
                        });
                    },
                    no: function (index) {
                        layer.close(index);
                    }
                });
            },
        };
        win_exp(fn);

        let cols = [[
            {
                field: 'staff_no',
                title: '员工编号',
                align: 'center',
                width: 100,
            },
            {
                field: 'nickname',
                title: '员工花名',
            },
            {
                field: 'vote_num',
                title: '已投票数',
            },
            {
                field: 'vote_num2',
                title: '未投票数',
            },
            {
                toolbar: '#tool_bar',
                title: '操作',
                fixed: 'right',
            }]];

        data_table.config.cols = cols;
        data_table.render();

    });
</script>
{/block}